data segment 
	n db ?
	table db 100 dup(?)
	char db ?
data ends

code segment
main proc far
	assume ds:data,cs:code
start:
	push ds
	sub ax,ax
	push ax

	mov ax,data
	mov ds,ax
	
	lea si,table
next:
	mov ah,01h
	int 21h
	mov [si],al
	inc si
	inc n
	cmp al,13
	jne next

	mov cl,n
	dec cl
	lea si,table
print:	
	mov al,[si]
	mov char,al
	call func
	inc si
	loop print
	ret 
main endp

func proc near
	push cx
	mov al,char
	lea di,table
	mov cl,n
	dec cl
	mov bl,0
begin:
	cmp al,[di]
	jne goto
	inc bl
goto:	
	inc di
	loop begin
	
	mov ah,2h
	mov dl,char
	int 21h

	mov ah,2h
	mov dl,3ah
	int 21h

	add bl,30h
	mov ah,2h
	mov dl,bl
	int 21h

	mov ah,2h
	mov dl,0dh
	int 21h

	mov ah,2h
	mov dl,0ah
	int 21h
	pop cx
	ret
func endp

code ends
	end start
